Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-06-2009, 02:13 PM   #1
LQ Newbie
Registered: Mar 2009
Posts: 6

Rep: Reputation: 0
problem routing eth0:1

Hello guys,
I am running openvpn and when i nat via eth0 it is working good.
But when i try to change the outgoing ip which is at my second interface eth0:1 i get this error:

# iptables -t nat -A POSTROUTING -s -o eth0:1 -j MASQUERADE
Warning: wierd character in interface `eth0:1' (No aliases, :, ! or *).

How can i make an alias or something to make it work. Please help

Last edited by mirostz; 03-06-2009 at 02:17 PM.
Old 03-06-2009, 02:43 PM   #2
LQ Guru
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Iptables doesn't recognize aliases, so you will have to rely on source range and eth0
Old 03-07-2009, 06:32 AM   #3
LQ Newbie
Registered: Mar 2009
Posts: 6

Original Poster
Rep: Reputation: 0
Can someone give me a solution on this ?
Old 03-07-2009, 06:37 AM   #4
Senior Member
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375

Rep: Reputation: 217Reputation: 217Reputation: 217
Given billymayday's post above I would guess something like

iptables -t nat -A POSTROUTING -s -o eth0 -j MASQUERADE

I guess... that could be wrong tho! So I wouldn't try it until someone can confirm that.

Last edited by r3sistance; 03-07-2009 at 06:38 AM.
Old 03-07-2009, 07:21 AM   #5
LQ Newbie
Registered: Mar 2009
Posts: 6

Original Poster
Rep: Reputation: 0
r3sistance thanks for your reply
this command is working pretty good:
iptables -t nat -A POSTROUTING -s -o eth0 -j MASQUERADE

The thing is i want to use my eth0:1 or eth0:2 interface when i try to add them i get the error about wierd character in interface.

That's why i am asking if someone know how to make it work with eth0:1 ...
Old 03-07-2009, 10:48 AM   #6
LQ Newbie
Registered: Mar 2009
Posts: 6

Original Poster
Rep: Reputation: 0
hello guys i find a way to do it and i will share it with you so maybe it will help to someone:

eth0 75.x.x.1
eth0:1 75.x.x.2

locatel ip:

all you have to do is just type:
iptables -t nat -A POSTROUTING -s -o eth0 -j SNAT --to-source 75.x.x.2

and your outgoing ip will be 75.x.x.2

have fun


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
eth1 on second NIC stops routing on eth0 BethR Linux - Networking 9 01-30-2008 09:51 AM
Routing for eth0 and wlan0 with static IPs on the same network. kelvinlo Linux - Wireless Networking 3 10-15-2007 05:54 PM
eth0 not in routing table thymes Linux - Wireless Networking 20 11-07-2005 08:21 AM
eth0+ppp0 routing kwlg Linux - Networking 5 07-18-2005 06:50 PM
Internal Routing eth1 to eth0 Dataforce Linux - Networking 3 04-02-2004 10:41 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:17 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration