Masquerade based on MAC address

Posted on 2010-01-07
Last Modified: 2013-12-15
I want to share the internet connection to one particular client pc. currently I am using iptables Masquerade based on IP address. I want to change client IP adress to client MAC address.
Question by:rajasekarramasamy
    LVL 2

    Accepted Solution

    You can use "-m mac --mac-source XX:XX:XX:XX:XX:XX" part of your rules set , Like only permit 80 request from that machine of MAC Addreess.

    Author Comment


    iptables -t nat -A POSTROUTING -m mac --mac-source xx:xx:xx:xx:xx:xx -j MASQUERADE

    The above rule is not working. it showing some error like this

    Iptables: Invalid argument

    Please check my rule.
    LVL 39

    Assisted Solution

    You are too late in the chain, the test needs to be done when entering... see article...
    (INPUT, FORWARD, PREROUTING) are the chains to add the rule too.
    So you have to block all forwards except these that are allowed.
    Anything that eventualy reaches the output path needs to be natted.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
    Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now