Routing or Iptables connections by hostname or ip address


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Routing or Iptables connections by hostname or ip address
# 1  
Old 04-28-2010
CPU & Memory Routing or Iptables connections by hostname or ip address

edit; I found a solution that works, see thread #3 https://www.unix.com/302417065-post3.html

Hi there,

I have a small dedicated server that has four ip addresses and by default my httpd sends request using the servers main ip for all outbound connections.

I'm quite amateur at routing and iptables I figured I'd sign up here and ask the gurus for advice on the subject.

So here is the situation that I am having, my server that uses the ip 127.0.20.1 uses 127.0.20.1 for all outbound connections which is fine for almost everything, however lets say I want to connect to some.hostname or 10.0.0.74 etc etc is there a quick routing or ip tables trick/tip to simply make all connections requested to connect to 10.0.0.74 use 127.0.20.4 as opposed to using 127.0.20.1


Thank you all in advance for all advice or solutions.

--------
Mooofa Smilie

Last edited by mooofa; 04-28-2010 at 12:44 PM..
# 2  
Old 04-28-2010
Is that really on loopback and internal IPs, or have you sanitized the addresses? Right now you're telling me your server has several IPs on the same subnet, which is a little odd.
# 3  
Old 04-28-2010
Hi

I actually solved my issue I meant to edit my thread but forgot to last night, and for anyone else needing a solution like this using routing its acutally really easy i just read the manual on route, solved everything.

Command issued as root

Code:
route add -host 192.168.2.105 dev eth0:3

You change 192.168.2.105 to whatever destination ip you are wanting to use a different interface on, and eth0 with :1 - :3 etc etc, determines your virtual interface.


Hope this helps others in similar situations, cheers!

---------- Post updated at 10:45 AM ---------- Previous update was at 10:43 AM ----------

Quote:
Originally Posted by Corona688
Is that really on loopback and internal IPs, or have you sanitized the addresses? Right now you're telling me your server has several IPs on the same subnet, which is a little odd.
The address were simply sanitized for theory crafting.
# 4  
Old 04-28-2010
These changes will go away when the server is restarted.
# 5  
Old 04-28-2010
Quote:
Originally Posted by Corona688
These changes will go away when the server is restarted.
That is correct so be sure to add it to your custom start up scripts if your server is off and on often.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. IP Networking

Source IP address field in RREP on DSR routing

Hello I have a question about routing in MANET using Dynamic Source Routing protocol. IN RFC4728 (DSR) in section "IP fields" of RREP (Route Reply) packet we have this: ok. I read in several books and also in rfc4728 that: when a source node (node that initiate route discovery process)... (1 Reply)
Discussion started by: acu281
1 Replies

2. Solaris

SMTP relay one (1) hostname with two (2) IP Address

Hi, Anyone can help? Currently : I'm am using a smtp smart relay, 1 hostname but different IP Address 192.168.2.108 and 192.168.2.109). I'm using "smtp.mailhostname.com mailhost" and having an IP Address 192.168.2.108, but there is a certain minutes/seconds that the IP Address will... (2 Replies)
Discussion started by: fspalero
2 Replies

3. AIX

Mutt from address and hostname

Mutt 1.2.3.1i AIX 5.3.12.1 We need to send email to external addresses. But are having problems with the sent-from hostname. They're going out with @server.mycompany.com. We need them to be @mycompany.com. I'm setting from and hostname with -e 'set from="From... (1 Reply)
Discussion started by: Papa Lee
1 Replies

4. IP Networking

iptables - MAC routing

Hi all, I have a solution where a system can have multiple physical interfaces but a single IP address. I am looking to insert a Squid proxy (that will also perform source NAT), but the return packets must go back to the correct interface. client network is 10.x.x.x network between the... (4 Replies)
Discussion started by: wabbit02
4 Replies

5. Shell Programming and Scripting

iptables - Limit Connections Per Second

Hi, Sorry for my english. I need a shell script. . If IP make more than 300 connection attempts to port:80 within 10 seconds I want block it for 3600 second in iptables. Thank you ver much for help. (2 Replies)
Discussion started by: tara123
2 Replies

6. UNIX for Dummies Questions & Answers

Solaris - How to get IP Address from a hostname?

We are using Solaris as our database OS. Can you please help me to know how can i get the IP address of a solaris machine in my network from its hostname? e.g. We have a remote database server with the hostname as xyz. Without connecting to the database OS, can i get the IP address of xyz OS from... (1 Reply)
Discussion started by: Anmol Sharma
1 Replies

7. Shell Programming and Scripting

Convert IP address (within a line) to hostname

I have a tricky problem, and I'm quite the scripting newb. I have Cisco ACLs that have IP addresses in them. I'd like to convert the IP's to hostnames for easier analysis. A sample ACL input file would be (I've obfuscated the IPs): access-list acl-secure-out line 1 extended permit icmp any... (3 Replies)
Discussion started by: scolazz
3 Replies

8. Shell Programming and Scripting

Read Hostname and Return IP Address

Dear Experts, I have a text file on my itanium box which contains list of nearly 1000 hostnames. I do not have the IP Address of them. I want read each entry from the text file and want to do a nslookup to the DNS Server and get the IP Adresses and put them in another file in the format... (1 Reply)
Discussion started by: PrasannaKS
1 Replies

9. Solaris

How can I find the number of connections from a specific IP address historically?

I am using netstat -na command to find out the number of network connections from a specific machine, but this returns information as of now. His there anyway that I can find out this information from yesterday or earlier. Thanks, Tim (3 Replies)
Discussion started by: tkimber
3 Replies

10. UNIX for Dummies Questions & Answers

IP address/hostname problem

I have a problem that when I am pinging with the IP address it is giving me whether a server is alive or not but when I am trying it with hostname it is giving unknown host I have checked in /etc/hosts file and the IP address and hostname are both there...still the problem is there.. Can... (1 Reply)
Discussion started by: uLearner
1 Replies
Login or Register to Ask a Question