MAC Address on Connection Sharing

Discussion in 'Linux Networking' started by Chienbinhso13, Nov 27, 2013.

  1. Chienbinhso13

    Chienbinhso13 New Member

    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    My computer have 2 NICs and I want to share Internet from eth0 to eth1 like that

    Internet <<==>> Router1 <<=>> eth0 <> Ubuntu gateway(My PC)* <> eth1 <<==>> Wifi Router <==> PC1,PC2,...


    I think I will config like this page. But I don't know if Router1 can see MAC of eth1 and PC1, PC2,... or it can only see MAC of eth0. Because I want to hide MAC of all device.
    Someone can help me how to config to hide all MAC address of my device Sorry because my English not good
  2. Rodrigo

    Rodrigo New Member

    Messages:
    18
    Likes Received:
    8
    Trophy Points:
    3
    The router1 can not see any MAC addresses beyond your Linux Box(your linux box is like a router too). May be you need a bridge try with ebtables.


    I didn't any link, please share the link again.
  3. Chienbinhso13

    Chienbinhso13 New Member

    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    I can't post a link.
    I'm sorry.
    So, this is content of that page :
    Gateway set up
    The following example will focus on the most common gateway setup: an Ubuntu computer with two wired network adapters (eth0 and eth1) hosting ICS to a static internal network configured for the 192.168.0.x subnet.
    For this example, eth0 is used to represent the network card connected to the Internet, and eth1 represents the network card connected to a client PC. You can replace eth0 and eth1 as needed for your situation. Also, any
    private IP subnet can be used for the internal network IP addresses.
    In summary:
    eth0 = the network adapter with internet (external or WAN).
    eth1 = the network adapter to which a second computer is attached (internal or LAN).
    192.168.0.x = IP subnet for eth1
    Your setup may be different. If so, make sure to change them accordingly in the following commands.
    Configure internal network card
    Configure your internal network card (eth1) for static IP like so:
    sudo ip addr add 192.168.0.1/24 dev eth1
    The external and internal network cards cannot be on the same subnet.
    Configure NAT
    Configure iptables for NAT translation so that packets can be correctly routed through the Ubuntu gateway.
    sudo iptables -A FORWARD -o eth0 -i eth1 -s 192.168.0.0/24 -m conntrack --ctstate NEW -j ACCEPT
    sudo iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
    sudo iptables -t nat -F POSTROUTING
    sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
    The first rule allows forwarded packets (initial ones). The second rule allows forwarding of established connection packets (and those related to ones that started). The third rule does the NAT.
    IPtables settings need to be set-up at each boot (they are not saved automatically), with the following commands:
    1. Save the iptables:
    sudo iptables-save | sudo tee /etc/iptables.sav
    1. Edit/etc/rc.local and add the following lines before the "exit 0" line:
    iptables-restore < /etc/iptables.sav
    Enable routing
    1. Configure the gateway for routing between two interfaces by enabling IP forwarding:
    sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
    1. Edit/etc/sysctl.conf, and (up to10.04) add these lines:
    net.ipv4.conf.default.forwarding=1
    net.ipv4.conf.all.forwarding=1
  4. Rodrigo

    Rodrigo New Member

    Messages:
    18
    Likes Received:
    8
    Trophy Points:
    3
    What MAC addresses do you want to hide? you want hide the router1's MAC address from the LAN? if that is the point your configuration it's right. if you want validated you can use tcpdump, wireshark on your Linux Box to sniff your traffic
    Last edited: Dec 2, 2013
  5. Chienbinhso13

    Chienbinhso13 New Member

    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Ok, thanks you!

Share This Page